import pygame


def __game_over():
    """游戏结束"""
    print("游戏结束")
    pygame.quit()
    exit()


class PEng:
    def __check_collide(self):
        """碰撞检测"""
        # 1.设置子弹摧毁敌机
        pygame.sprite.groupcollide(self.hero.bullets,
                                   self.enemy_group, True, True)
        # 2.敌机摧毁英雄
        enemies = pygame.sprite.spritecollide(self.hero,
                                              self.enemy_group, True)
        # 2.1判断列表是否有内容
        if len(enemies) > 0:
            # 让英雄牺牲
            self.hero.kill()
            # 结束游戏
            elif event.type == pygame.KEYDOWN:
                if event.key == K_a or event.key == K_LEFT:
                    print('left')
                    # 控制飞机让其向左移动
                    hero_plane.move_left()
                elif event.key == K_d or event.key == K_RIGHT:
                    print('right')
                    hero_plane.move_right()
                elif event.key[pygame.K_SPACE]:
                    print('space')
                    hero_plane.launch_bullet()